#!/usr/bin/python
import os;
import time;
import datetime;
print("Start");
n=time.strftime("%Y-%m-%d_%H%M%S");
ms=datetime.datetime.now().microsecond;
bakfilename="DataConvert.ini"+n+'('+str(ms)+')'+".bak";
os.rename("DataConvert.ini",bakfilename);
file=open(bakfilename,'rU');
file2=open("DataConvert.ini",'wb')

i=1;
bStart=False;
if hasattr(file,'newlines'):
    print(file.newlines);
    
for line in file:
    if line.startswith("["):
        if line.find("]"):
            print(line);
            bStart=True;
            i=1;
    if bStart:
        if line.startswith("SENTENCE"):
            s=line.split('=',1)
            if i<10:
                newline="SENTENCE"+str(i)+" = "+s[1].lstrip();
            elif i<100:
                newline="SENTENCE"+str(i)+" = "+s[1].lstrip();
            else:
                newline="SENTENCE"+str(i)+" = "+s[1].lstrip();
            i=i+1;
        else:
            newline=line;
    else:
        newline=line;
    newline=newline.replace('\n','\r\n');
    file2.write(newline.encode("gbk"));
file.close();
file2.close();
print("end");
                
